<?php
declare (strict_types = 1);

namespace app\command;

use app\admin\model\Taobao;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use think\Db;

class UpdateTaoBao extends Command
{
    protected function configure()
    {
        // 指令配置
        $this->setName('UpdateTaoBao');
        // 设置参数
        $this->setDescription('素材同步')->setHelp("php think UpdateTaoBao");
    }

    protected function execute(Input $input, Output $output)
    {
         $taobao = (new Taobao())->select()->toArray();
         foreach ($taobao as $items){
             $total = $items['nums'] * $items['price'];
             (new Taobao())->where(['id' => $items['id']])->update(['total_money' => $total]);
             echo $items['id']."\n";
         }
    }
}
